//提交
function createBtn() {
    var inputName = '';
    if ($('#inputName').val() == '' || $('#inputName').val() == null) {
        alert("活动名不能为空")
        return
    } else {
        inputName = $('#inputName').val();
    }
    var inputRoom = '';
    if ($('#inputRoom').val() == '' || $('#inputRoom').val() == null) {
        alert("教室选项未填（如若未定填写：待定）")
        return
    } else {
        inputRoom = $('#inputRoom').val();
    }
    var inputCount = '';
    if ($('#inputCount').val() == '' || $('#inputCount').val() == null) {
        alert("开选人数不能为空")
        return
    } else {
        inputCount = $('#inputCount').val();
    }
    var inputCredit = '';
    if ($('#inputCredit').val() == '' || $('#inputCredit').val() == null) {
        alert("活动学分未填")
        return
    } else {
        inputCredit = $('#inputCredit').val();
    }

    var selectedTime = $("#selectedTime").val();
    if (selectedTime == null || selectedTime == "") {
        alert("开放选择时间未填写")
        return;
    }

    var actionDateLocal = $("#actionDateLocal").val();
    if (actionDateLocal == null || actionDateLocal == "") {
        alert("活动开始时间未填写")
        return;
    }

    var stopDateLocal = $("#stopDateLocal").val();
    if (stopDateLocal == null || stopDateLocal == "") {
        alert("活动结束时间未填写")
        return;
    }

    var remark = $('#remark').val();

    //发送给后台
    $.post(
        "/activities/createActivity",
        {
            activityName: inputName,
            classroom: inputRoom,
            count: inputCount,
            credit: inputCredit,
            remarks: remark,
            startTime: actionDateLocal,
            endTime: stopDateLocal,
            selectedTime:selectedTime
        },
        function (response) {
            alert(response.msg)
            if (response.code == 0) {
                window.location.href = "/activities/history";
            }
        }
    )
}


function editBtn() {
    var inputName = '';
    if ($('#inputName').val() == '' || $('#inputName').val() == null) {
        alert("活动名不能为空")
        return
    } else {
        inputName = $('#inputName').val();
    }
    var inputRoom = '';
    if ($('#inputRoom').val() == '' || $('#inputRoom').val() == null) {
        alert("教室选项未填（如若未定填写：待定）")
        return
    } else {
        inputRoom = $('#inputRoom').val();
    }
    var inputCount = '';
    if ($('#inputCount').val() == '' || $('#inputCount').val() == null) {
        alert("开选人数不能为空")
        return
    } else {
        inputCount = $('#inputCount').val();
    }
    var inputCredit = '';
    if ($('#inputCredit').val() == '' || $('#inputCredit').val() == null) {
        alert("活动学分未填")
        return
    } else {
        inputCredit = $('#inputCredit').val();
    }

    var actionDateLocal = $("#actionDateLocal").val();
    if (actionDateLocal == null || actionDateLocal == "") {
        alert("活动开始时间未填写")
        return;
    }

    var stopDateLocal = $("#stopDateLocal").val();
    if (stopDateLocal == null || stopDateLocal == "") {
        alert("活动结束时间未填写")
        return;
    }

    var remark = $('#remark').val();
    var activityId = $('#activityId').val();

    //发送给后台
    $.post(
        "/activities/editCourse",
        {
            courseId: courseId,
            courseName: inputName,
            classroom: inputRoom,
            count: inputCount,
            credit: inputCredit,
            deptId: inputDeptId,
            timetable: timetable,
            remarks: remark,
            activityId: activityId
        },
        function (response) {
            alert(response.msg)
            if (response.code == 0) {
                window.location.href="/activities/history";
            }

        }
    )

}